$(function () {

    function cycle() {
        var s = new Array();
        var num = 0;
        $(".checkbox").each(function () {
            if ($(this).is(":checked")) {
                s[num++] = $(this).attr("value");
            }
        });
        return s;
    }

    $("#selectAll").on("click", function () {
        $(".checkbox").each(function () {
            $(this).prop("checked", true);
        });
    });

    $("#unselectAll").on("click", function () {
        $(".checkbox").each(function () {
            $(this).prop("checked", false);
        });
    });

    $("#addexplain").on("click", function () {
        window.location.href = "/addexplain";
    });

    $('#edit').on("click",function () {
        var explains = cycle();
        if (explains == ''){
            alert("请选择商品后进行编辑操作");
        }else{
            window.location.href = "/editExplain?explains=" + explains;
        }
    });

    $("#delete").on("click",function () {
        var explains = cycle();
        if (explains == ''){
            alert("请选择商品后进行删除操作");
        } else{
            window.location.href = "/deleteExplains?explainsList=" + explains;
        }
    });
});